<template>
	<view class="container bg-w">
		<view class="header uni-flex uni-row flex-between">
			<uni-nav-bar title="待审核任务">
				<template slot='left'>
					<view class="flex width-100">
						<i class='iconfont iconfanhui' @click='goBack()'></i>
					</view>
				</template>
			</uni-nav-bar>
		</view>
		<view class="position-r-top">
			<view class="buildList" v-if="auditData.length>0">
				<view class="project-card" v-for="(item,index) in auditData" :key="index">
					<view class="project-card__head" @click="goToSubProjectInfo(item)">
						<view class="title">
							<text>{{ item.gaugingPoint }}</text>
						</view>
						<text class="state">{{ item.subProcessName }}</text>
					</view>
					<view class="project-card__body">
						<view>
							<text>上级子项：{{ item.subProjectName }}</text>
						</view>
						<text>上报时间：{{ item.reportTime }}</text>
					</view>
					<view class="project-card__foot"  @click="goToConstructionData(item)">
						<view>前往审批</view>
					</view>
				</view>
			</view>
			<view class="nodata" v-else>
				<text>暂无数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { findAuditPoints } from '@/common/api/ConstructionAudit'
	export default {
		data() {
			return {
				auditData: [],
				page: {
					projectId: '',
					pageNo: 1,
					pageSize: 10,
				}
			}
		},
		onLoad(params) {
			this.page.projectId = params.projectId;
		},
		onShow() {
			this.auditData = [];
			this.loadWaitAuditData();
		},
		methods: {
			goToConstructionData(item){
				uni.navigateTo({
				  url: `/pages/Application/ConstructionAudit/ConstructionProject/ProjectAudit/ProjectAudit?projectId=${item.projectId}&subProjectId=${item.subProjectId}&assessmentId=${item.assessmentId}`
				});
			},
			loadWaitAuditData(){
				findAuditPoints(this.page).then((res)=>{
					if(res.code == 20000){
						this.totalPage = res.data.pages;
						this.auditData = this.auditData.concat(res.data.records);
					}
				})
			},
			onReachBottom() { //上拉加载更多
				this.page.pageNo++
				if (this.page.pageNo <= this.totalPage) {
					this.loadWaitAuditData();
				}
			},
			onPullDownRefresh(){//下拉刷新
				this.page.pageNo = 1;
				this.auditData = [];
				this.loadWaitAuditData();
				setTimeout(function () {
						uni.stopPullDownRefresh();
				}, 1000);
			},
		}
	}
</script>

<style lang="less">
	.uni-searchbar{background-color: #F2F2F2;}
	.buildList{
		padding: 16rpx;
		background: #f9f9f9;
		.project-card{
			margin-bottom: 16rpx;
			color: #8C8C8C;
			border-radius: 10rpx;
			background: #fff;
			box-shadow: 0px 0px 5px rgba(0,0,0,.3);
			>.project-card__head{
				display: flex;
				height: 64rpx;
				line-height: 64rpx;
				color: #333;
				border-bottom: 1px solid #D6D6D6;
				border-radius: 10rpx 10rpx 0 0;
				>.title{
					flex: 1;
					padding: 0 20rpx;
					font-weight: bold;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
				>.state{
					width: 150rpx;
					color: #09aae9;
					text-align: center;
					>.uni-icons{
						/deep/ span{
							font-size: 30rpx;
						}
					}
				}
			}
			>.project-card__body{
				padding: 10rpx 20rpx 0 36rpx;
				>view{
					display: flex;
				}
				text{
					position: relative;
				}
				text:before {
					content: '';
					position: absolute;
					top: 14rpx;
					left: -18rpx;
					display: block;
					width: 6rpx;
					height: 6rpx;
					border-radius: 50%;
					border: 1px solid #09aae9;
					background: #09aae9;
				}
			}
			>.project-card__foot{
				display: flex;
				padding: 20rpx 0;
				justify-content: center;
				>view{
					width: 250rpx;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					color: #fff;
					border-radius: 10rpx;
					background: #09aae9;
				}
			}
		}
	}
</style>
